package com.qf.dao.impl;

import com.qf.dao.CategoryDao;
import com.qf.pojo.Category;
import com.qf.utils.JdbcUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

public class CategoryDaoImpl implements CategoryDao {
    @Override
    public List<Category> selectCategory() throws SQLException {
        //访问数据库,获取数据
        QueryRunner qr =  new QueryRunner(JdbcUtils.getDataSource());
        //sql语句
        String sql = "select * from category";
        List<Category> list = qr.query(sql, new BeanListHandler<Category>(Category.class));

        return list;
    }
}
